home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / hMailServer / hMailServer-4.1-Build-136.exe / {app} / Addons / Squirrelmail Plugins / hmailserver_vacation / options.php < prev    next >
PHP Script  |  2005-03-14  |  6KB  |  206 lines

  1. <?php
  2.  
  3.    
  4.    chdir('..');
  5.    define('SM_PATH','../');
  6.  
  7.  
  8.  
  9.    // include compatibility plugin
  10.    //
  11.    if (defined('SM_PATH'))
  12.       include_once(SM_PATH . 'plugins/compatibility/functions.php');
  13.    else if (file_exists('../plugins/compatibility/functions.php'))
  14.       include_once('../plugins/compatibility/functions.php');
  15.    else if (file_exists('./plugins/compatibility/functions.php'))
  16.       include_once('./plugins/compatibility/functions.php');
  17.  
  18.  
  19.    
  20.    if (compatibility_check_sm_version(1, 3))
  21.    {
  22.       include_once (SM_PATH . 'include/validate.php');
  23.       include_once (SM_PATH . 'functions/page_header.php');
  24.       include_once (SM_PATH . 'include/load_prefs.php');
  25.    }
  26.    else
  27.    {
  28.       include_once ('../src/validate.php');
  29.       include_once ('../functions/page_header.php');
  30.       include_once ('../src/load_prefs.php');
  31.    }
  32.    
  33.    
  34.    
  35.    global $vacationMessageSubmit, $messageText, $vacationStatus, $messageSubject, 
  36.           $username, $data_dir, $color;
  37.  
  38.  
  39.    // get flag that tells us if this is a vacation
  40.    // message submission
  41.    //
  42.    compatibility_sqextractGlobalVar('vacationMessageSubmit');
  43.  
  44.    // if a message and other info was submitted, process it here
  45.    //
  46.    
  47.  
  48.    if (isset($vacationMessageSubmit) && $vacationMessageSubmit == 1)
  49.    {
  50.  
  51.       compatibility_sqextractGlobalVar('messageText');
  52.       compatibility_sqextractGlobalVar('vacationStatus');
  53.       compatibility_sqextractGlobalVar('messageSubject');
  54.       compatibility_sqextractGlobalVar('ccAddresses');
  55.       compatibility_sqextractGlobalVar('keepMessages');
  56.  
  57.       // turn on vacation messaging
  58.       //
  59.       
  60.       $obAccount = GetAccountObject($username);
  61.       
  62.       if (isset($vacationStatus) && $vacationStatus == "on")
  63.       {
  64.  
  65.          $obAccount->VacationMessage = $messageText;
  66.          $obAccount->VacationSubject = $messageSubject;
  67.          $obAccount->VacationMessageIsOn = true;
  68.          $obAccount->Save();         
  69.       }
  70.       else
  71.       {
  72.          $obAccount = GetAccountObject($username);
  73.          $obAccount->VacationMessage = $messageText;
  74.          $obAccount->VacationSubject = $messageSubject;
  75.          $obAccount->VacationMessageIsOn = false;
  76.          $obAccount->Save();                    
  77.  
  78.       }
  79.  
  80.  
  81.       $location = '../../src/options.php';
  82.       header('Location: ' . $location);
  83.       exit(0);
  84.  
  85.    }
  86.  
  87.         
  88.    // pull previous settings from user prefs
  89.    //
  90.    $obAccount = GetAccountObject($username);
  91.    $messageText = $obAccount->VacationMessage();
  92.    $messageSubject = $obAccount->VacationSubject();
  93.    $vacationStatus = $obAccount->VacationMessageIsOn();
  94.  
  95.    displayPageHeader($color, 'None', 'document.forms[0].elements["messageText"].focus();');
  96.    echo '<br>';
  97.  
  98.  
  99.    echo '<form method="POST"><input type="hidden" name="vacationMessageSubmit" value="1">'
  100.       . '<table width=95% align=center cellpadding=2 cellspacing=2 border=0>'
  101.       . '<tr><td bgcolor="' . $color[0] . '">'
  102.       . '<center><b>'
  103.       . _("Vacation / Autoresponder");
  104.  
  105.    ?>
  106.  
  107.       </b></center>
  108.       </td>
  109.    </tr>
  110.    <tr> 
  111.       <td align="center">
  112.          <table width="70%" cellspacing="2">
  113.             <tr>
  114.                <td valign="top">
  115.                   <br>
  116.                   <input type="checkbox" name="vacationStatus" value="on" <?php
  117.                                                    if ($vacationStatus == 'on') echo ' CHECKED' ?>>
  118.                </td>
  119.                <td>
  120.                   <br>
  121.                   <b><?php echo _("Activate vacation autoresponder") ?></b>
  122.                </td>
  123.             </tr>
  124.             <tr>
  125.                <td colspan="2"> 
  126.                   <br>
  127.                   <b><?php echo _("Message text"); ?></b>:
  128.                   <br>
  129.                   <textarea name="messageText" rows="5" cols="50" wrap="off"><?php echo eregi_replace('<br[[:space:]]*/?[[:space:]]*>', "\n", $messageText); ?></textarea>
  130.                </td>
  131.             </tr>
  132.             <tr>
  133.                <td colspan="2">
  134.                   <br>
  135.                   <b><?php echo _("Message subject") . '</b> ' 
  136.                         . _("(leave blank to use standard \"RE:\" syntax)"); ?>:
  137.                   <br>
  138.                   <input type="text" name="messageSubject" size="60" value="<?php echo $messageSubject; ?>">
  139.                </td>
  140.             </tr>
  141.             <tr>
  142.                <td align=right colspan="2">
  143.                   <br>
  144.                   <input type="submit" value="<?php echo _("Submit"); ?>">
  145.                </td>
  146.             </tr>
  147.          </table>
  148.       </td>
  149.    </tr>
  150. </table>
  151. </form>
  152. </body>
  153. </html>
  154.  
  155. <?php
  156.  
  157. exit(0);
  158.  
  159.  
  160.  
  161. // displays simple error output page
  162. //
  163. function showError($message)
  164. {
  165.  
  166.    global $color;
  167.    displayPageHeader($color, 'None');
  168.    echo '<br><br><center><font color="' . $color[2] . '"><b>'
  169.       . $message
  170.       . '</b></font></center></body></html>';
  171.  
  172. }
  173.  
  174. function GetAccountObject($username)
  175. {
  176.     // Extract domain part from email address
  177.     $iAtPos = strpos($username, '@');
  178.     
  179.     $DomainName = substr($username, $iAtPos + 1);
  180.  
  181.     $hCOMApp = new COM("hMailServer.Application");
  182.     
  183.     $obDomain = $hCOMApp->Domains->ItemByName($DomainName);
  184.     
  185.     if (!isset($obDomain))
  186.     {
  187.         echo "Can not fetch domain object.!";
  188.         die;
  189.     }
  190.     
  191.     $obAccount = $obDomain->Accounts->ItemByAddress($username);
  192.     
  193.     if (!isset($obAccount))
  194.     {
  195.         echo "Can not fetch account object.!";
  196.         die;
  197.  
  198.     }
  199.     
  200.     return $obAccount;
  201.  
  202. }
  203.  
  204.  
  205. ?>
  206.